<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
   <meta charset="utf-8"/>
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
   <meta name="description" content="Bootstrap Admin App + jQuery"/>
   <meta name="keywords" content="app, responsive, jquery, bootstrap, dashboard, admin"/>
   <title>找回密码</title>
   <link rel="icon" href="/img/icon.ico" type="image/x-icon" />
   <link rel="stylesheet" th:href="@{/vendor/fontawesome/css/font-awesome.min.css}"></link>
   　　<link rel="stylesheet" th:href="@{/vendor/simple-line-icons/css/simple-line-icons.css}"></link>
   　　<link rel="stylesheet" th:href="@{/media/css/bootstrap.css}" id="bscss"></link>
   　　<link rel="stylesheet" th:href="@{/media/css/app.css}" id="maincss"></link>
   　　<link rel="stylesheet" th:href="@{/media/css/theme-i.css}" id="maincss"></link>
</head>
<body>
<div class="wrapper">
   <div class="block-center mt-xl wd-xl">
      <div class="panel panel-dark panel-flat">
         <div class="panel-heading text-center">
            <h3>我的标签</h3>
         </div>
         <div class="panel-body" id="setNewPwdPage">
            <p class="text-center pv">重置密码</p>
            <form id="form" data-parsley-validate="true" onsubmit="return false">
               <p class="text-center pv">请填写您的新密码</p>
               <div class="form-group has-feedback">
                  <input id="newpassword" name="newpassword" type="password" placeholder="请输入6-20位字母数字组合" class="form-control" v-model="password" required="required" data-parsley-required-message="请输入新密码" pattern="^(?![0-9]+$)(?![a-zA-Z]+$)(?![^0-9a-zA-Z]+$)\S{6,20}$" data-parsley-pattern-message="请输入6-20位字母数字组合"/>
                  <span class="fa fa-lock form-control-feedback text-muted"></span>
               </div>
               <button id="setNewPwdButton" onclick="setNewPwd();" class="btn btn-block btn-primary mt-lg">提交</button>
            </form>
            <p></p>
            <div id="errorMsg" class="alert alert-danger text-center" style="display:none;"></div>
         </div>
      </div>
      <div class="p-lg text-center">
         <span>CopyRight</span>
         <span>&copy;</span>
         <span>2017</span>
         <span>tianff.self</span>
      </div>
   </div>
</div>
<script th:src="@{/webjars/jquery/2.2.4/dist/jquery.min.js}"></script>
<script th:src="@{/webjars/vue/1.0.24/vue.min.js}"></script>
<script th:src="@{/webjars/vue-resource/0.7.0/dist/vue-resource.min.js}"></script>
<script th:src="@{/vendor/parsleyjs/dist/parsley.min.js}"></script>
<script type='text/javascript'>
   /*<![CDATA[*/
   function setNewPwd() {
       var ok = $('#form').parsley().isValid({force: true});
       if(!ok){
           return;
       }
//       var email = getQueryString("email");
//       var sid = getQueryString("sid");
       var url = "/session/user/pass/new";
       $.ajax({
           url : url,
           data : {
               newpwd:$("#newpassword").val()
           },
           type : 'POST',
           //dataType : "json",
           success : function(data) {
               if(data == '200'){
                   window.open('/web/success','_self');
               }else{
                   $("#errorMsg").html('链接已失效');
                   $("#errorMsg").show();
               }
           }
       });
   }
   function getQueryString(name) {
       var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
       var r = window.location.search.substr(1).match(reg);
       if (r != null) return unescape(r[2]);
       return null;
   }
   /*]]>*/
</script>
</body>
</html>